/*
 * Query.cpp
 *
 */

#include "Query.h"

Query::Query() : id(0), serviceId(0), userId(0) {}

Query::~Query() {}

Query::Query(const Query& other) {
	id = other.id;
	serviceId = other.serviceId;
	userId = other.userId;
	date = other.date;
	time = other.time;
	request = other.request;
	response = other.response;
	responseDate = other.responseDate;
	time = other.responseTime;
	hidden = other.hidden;
}


Query& Query::operator=(const Query& other) {
	id = other.id;
	serviceId = other.serviceId;
	userId = other.userId;
	date = other.date;
	time = other.time;
	request = other.request;
	response = other.response;
	responseDate = other.responseDate;
	time = other.responseTime;
	hidden = other.hidden;
	return *this;
}

BigInt Query::size() const {
	return 7 + 3*sizeof(BigInt) + date.length() + time.length() + request.length() + response.length()
			+ responseDate.length() + responseTime.length() + hidden.length();
}

void Query::serialize(ISerializer& serializer) const {
	serializer.serializeUnsignedLongInt(id);
	serializer.serializeUnsignedLongInt(serviceId);
	serializer.serializeUnsignedLongInt(userId);
	serializer.serializeString(request);
	serializer.serializeString(date);
	serializer.serializeString(time);
	serializer.serializeString(response);
	serializer.serializeString(responseDate);
	serializer.serializeString(responseTime);
	serializer.serializeString(hidden);
}

void Query::unserialize(IUnserializer& unserializer) {
	id = unserializer.unserializeUnsignedLongInt();
	serviceId = unserializer.unserializeUnsignedLongInt();
	userId = unserializer.unserializeUnsignedLongInt();
	request = unserializer.unserializeString();
	date = unserializer.unserializeString();
	time = unserializer.unserializeString();
	response = unserializer.unserializeString();
	responseDate = unserializer.unserializeString();
	responseTime = unserializer.unserializeString();
	hidden = unserializer.unserializeString();
}
